package com.yzw.common.dto;

import com.yzw.common.constant.ResultCode;
import lombok.AllArgsConstructor;
import lombok.Data;

/**
 * @Author Yzw
 * @Description TODO
 * @Date 2023/5/1 13:48
 * @Version 1.0
 */
@Data
@AllArgsConstructor
public class R {


    private Integer code;
    private String message;
    private Object data;


    public static R success(String message,Object data ){
        return new R(ResultCode.SUCCESS.getCode(),message,data);
    }


    public static R error(String message ){
        return new R(ResultCode.ERROR.getCode(),message,null);
    }

    //自定义异常的时候使用
    public static R error( Integer code,String message ){
        return new R(code,message,null);
    }
}
